﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace MDIDemo.Windows.Report
{
    public partial class frmBaoCaoBGCNPhatSinh : DevExpress.XtraEditors.XtraForm
    {
        DataSet _ds = null;
        string _mahang = "";

        public string Mahang
        {
            get { return _mahang; }
            set { _mahang = value; }
        }

        public DataSet DataSource { get { return _ds; } }

        public frmBaoCaoBGCNPhatSinh()
        {
            InitializeComponent();
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            _ds = BuildDataSourceBGCONGNO();
            if (_ds.Tables.Count == 0)
            {
                XtraMessageBox.Show("Dữ liệu không tồn tại!");
                return;
            }
            bool isdata = false;
            foreach (DataTable dt in _ds.Tables)
            {
                if (dt.Rows.Count > 0)
                {
                    isdata = true;
                    break;
                }
            }
            if (isdata == false)
            {
                XtraMessageBox.Show("Dữ liệu không tồn tại!");
                return;
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }

        public DataSet BuildDataSourceBGCONGNO()
        {
            DataSet _ds = null;
            string query = @"exec procGIAODICH_getallByNgayCT @NGAYCT='{0:yyyy-MM-dd}'";
            query = string.Format(query, dtpNgay.EditValue);
            BUS.CommonControl ctr = new BUS.CommonControl();
            _ds = ctr.executeSelectQueries(query);
            return _ds;
        }

        private void frmBaoCaoBGCNPhatSinh_Load(object sender, EventArgs e)
        {
            dtpNgay.EditValue = frmMain.__ngayMoSo;
        }
    }
}